package com.ruoyi.auth.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class DubboRegistryAdapter implements ApplicationListener<ApplicationReadyEvent> {

    @Override
    public void onApplicationEvent(ApplicationReadyEvent   event) {
        /*DubboServiceMetadataRepository dubboServiceMetadataRepository = event.getApplicationContext().getBean(DubboServiceMetadataRepository.class);
        Set<String> subscribedServices = dubboServiceMetadataRepository.getSubscribedServices();
        if (!ObjectUtils.isEmpty(subscribedServices)) {
            DiscoveryClient DiscoveryClient = event.getApplicationContext().getBean(DiscoveryClient.class);
            for (String subscribedService : subscribedServices) {
                log.info("主动探测订阅服务:" + subscribedService);
                ServiceInstancesChangedEvent changedEvent = new ServiceInstancesChangedEvent(subscribedService, DiscoveryClient.getInstances(subscribedService));
                event.getApplicationContext().publishEvent(changedEvent);
            }
        }*/
    }
}
